﻿<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="security"
	uri="http://www.springframework.org/security/tags"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@page import="java.io.FileOutputStream"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.io.File"%>
<%@page import="java.io.OutputStream"%>
<HTML>
<HEAD>
<TITLE>RestFinder - wszystko o restauracjach w twoim mieście!</TITLE>
<META HTTP-EQUIV="Content-Type"
	CONTENT="text/html; charset=windows-1250">
<!-- ImageReady Preload Script (index.psd) -->
<SCRIPT TYPE="text/javascript">
<!--
	function newImage(arg) {
		if (document.images) {
			rslt = new Image();
			rslt.src = arg;
			return rslt;
		}
	}

	function changeImages() {
		if (document.images && (preloadFlag == true)) {
			for ( var i = 0; i < changeImages.arguments.length; i += 2) {
				document[changeImages.arguments[i]].src = changeImages.arguments[i + 1];
			}
		}
	}

	var preloadFlag = false;
	function preloadImages() {
		if (document.images) {
			moje_konto = newImage("images/moje_konto.jpg");
			news = newImage("images/news.jpg");
			szukaj = newImage("images/szukaj.jpg");
			top = newImage("images/top.jpg");
			wyloguj = newImage("images/wyloguj.jpg");
			preloadFlag = true;
		}
	}
// -->
</SCRIPT>
<!-- End Preload Script -->
<link href="css/styles.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0
	MARGINHEIGHT=0 ONLOAD="preloadImages();">
	<center>

		<!-- ImageReady Slices (index.psd) -->
		<TABLE WIDTH=775 BORDER=0 CELLPADDING=0 CELLSPACING=0>
			<TR>
				<TD COLSPAN=5><IMG SRC="images/m1.jpg" WIDTH=313 HEIGHT=93
					ALT="">
				</TD>
				<TD COLSPAN=2><A HREF="mojekonto.htm"
					ONMOUSEOVER="window.status='home page'; changeImages('home_page', 'images/moje_konto-over.jpg'); return true;"
					ONMOUSEOUT="window.status=''; changeImages('home_page', 'images/moje_konto.jpg'); return true;">
						<IMG NAME="home_page" SRC="images/moje_konto.jpg" WIDTH=95
						HEIGHT=93 BORDER=0 ALT="home page"> </A>
				</TD>
				<TD COLSPAN=2><A HREF="news.htm"
					ONMOUSEOVER="window.status='about us'; changeImages('about_us', 'images/news-over.jpg'); return true;"
					ONMOUSEOUT="window.status=''; changeImages('about_us', 'images/news.jpg'); return true;">
						<IMG NAME="about_us" SRC="images/news.jpg" WIDTH=92 HEIGHT=93
						BORDER=0 ALT="about us"> </A>
				</TD>
				<TD COLSPAN=3><A HREF="szukaj.htm"
					ONMOUSEOVER="window.status='location'; changeImages('location', 'images/szukaj-over.jpg'); return true;"
					ONMOUSEOUT="window.status=''; changeImages('location', 'images/szukaj.jpg'); return true;">
						<IMG NAME="location" SRC="images/szukaj.jpg" WIDTH=83 HEIGHT=93
						BORDER=0 ALT="location"> </A>
				</TD>
				<TD COLSPAN=3><A HREF="logout.htm"
					ONMOUSEOVER="window.status='contacts'; changeImages('contacts', 'images/wyloguj-over.jpg'); return true;"
					ONMOUSEOUT="window.status=''; changeImages('contacts', 'images/wyloguj.jpg'); return true;">
						<IMG NAME="contacts" SRC="images/wyloguj.jpg" WIDTH=92 HEIGHT=93
						BORDER=0 ALT="contacts"> </A>
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=93 ALT="">
				</TD>
			</TR>
			<TR>
				<TD COLSPAN=8 ROWSPAN=2><IMG SRC="images/m2.jpg" WIDTH=425
					HEIGHT=228 ALT="">
				</TD>
				<TD COLSPAN=9><IMG SRC="images/m3index.jpg" WIDTH=350
					HEIGHT=119 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=119 ALT="">
				</TD>
			</TR>
			<TR>
				<TD WIDTH=319 HEIGHT=109 COLSPAN=7 align="left" valign="top"
					class="text2">Zalogowany jako: <security:authentication
						property="principal.username" /> <br />
					<h1>
						Witaj,
						<c:out value="${user.name}" />
						!
					</h1>
				</TD>
				<TD COLSPAN=2><IMG SRC="images/spacer.gif" WIDTH=31 HEIGHT=109
					ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=109 ALT="">
				</TD>
			</TR>




			<TD><IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=47 ALT="">
			</TD>
			</TR>
			<TR>
				<TD><IMG SRC="images/spacer.gif" WIDTH=61 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=144 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=44 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=35 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=29 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=89 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=6 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=17 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=75 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=7 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=29 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=47 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=67 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=6 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=88 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=8 HEIGHT=1 ALT="">
				</TD>
				<TD><IMG SRC="images/spacer.gif" WIDTH=23 HEIGHT=1 ALT="">
				</TD>
				<TD></TD>
			</TR>
		</TABLE>
		<div class="tabbed-area">

			<ul class="tabs group">
				<li><a href="#box-one">Moje konto</a>
				</li>
				<li><a href="#box-two">Moje dane personalne</a>
				</li>
				<li><a href="#box-three">Moja restauracja</a>
				</li>
				<li><a href="#box-four">Moja aktywność</a>
				</li>
			</ul>

			<div class="box-wrap">



				<div id="box-two" style="height: 340px">

					<h3 style="text-align: center">Moje dane personalne:</h3>
					<form:form action="changeuserdata.htm" commandName="user">
						<table>
							<tr>
								<td colspan="2"><span class="text1"
									style="text-align: right">Zmień swoje dane:</span>
								<td />


							</tr>
							<tr>
								<td>Imię :</td>
								<td><input type="text" name="name" value="${user.name }" />
								</td>
								<td><span style="color: red"><c:out
											value="${nameError}" /> </span>
								</td>

							</tr>
							<tr>
								<td>Email :</td>
								<td><input type="text" name="email" value="${user.email }" />
								</td>
								<td><span style="color: red"><c:out
											value="${emailError}" /> </span>
								</td>

							</tr>
							<tr>
								<td>Telefon:</td>
								<td><input type="text" name="telephone"
									value="${user.telephone}" /></td>
								<td><span style="color: red"><c:out
											value="${telephoneError}" /> </span>
								</td>

							</tr>
							<tr>
								<td>Adres:</td>
								<td><input type="text" name="street" value="${user.street}" />
								</td>
								<td><span style="color: red"><c:out
											value="${streetError}" /> </span>
								</td>

							</tr>
							<tr>
								<td>Miasto:</td>
								<td><select name="city">
										<c:forEach items="${cities}" var="value">
											<option value="${value}"
												<c:if test="${user.city == value}"> selected="selected" </c:if>>${value}</option>
										</c:forEach>
								</select>
								</td>
							</tr>
							<tr>
								<td>Kraj:</td>
								<td><select name="country">
										<c:forEach items="${countries}" var="value">
											<option value="${value}"
												<c:if test="${user.country == value}"> selected="selected" </c:if>>${value}</option>
										</c:forEach>
								</select>
								</td>
							</tr>
							<tr>
								<td colspan="2"><input type="submit" class="button"
									value="Zmień dane"></td>
							</tr>
						</table>
					</form:form>

				</div>
				
				<div id="box-three" style="height: 340px; overflow:scroll;">
					<h3 style="text-align: center">Moja restauracja:</h3>
					<c:if test="${testUserOwner == false}">
					<form:form action="myrestaurantadd.htm" commandName="restaurant">
						<table>
							<tr>
								<td colspan="2"><span class="text1"
									style="text-align: right">Dodaj restauracje:</span>
								<td />
							</tr>
							<tr>
								<td>Nazwa :</td>
								<td><form:input path="name" />
								</td>
								<td><span style="color: red"><c:out
											value="${nameError}" />
								</span>
								</td>
							</tr>
							<tr>
								<td>Adres :</td>
								<td><form:input path="street" />
								</td>
								<td><span style="color: red"><c:out
											value="${streetError}" />
								</span>
								</td>
							</tr>
							<tr>

								<td>Miasto :</td>

								<td><form:select path="city">

										<form:options items="${cities}" />


									</form:select>
								</td>


							</tr>
							<tr>

								<td>Kraj :</td>

								<td><form:select path="country">

										<form:options items="${countries}" />


									</form:select>
								</td>
							</tr>
														<tr>
								<td>Kod pocztowy :</td>
								<td><form:input path="postal_code" />
								</td>
								<td><span style="color: red"><c:out
											value="${postal_codeError}" />
								</span>
								</td>
							</tr>
														<tr>
								<td>Telefon :</td>
								<td><form:input path="telephone" />
								</td>
								<td><span style="color: red"><c:out
											value="${telephoneError}" />
								</span>
								</td>
							</tr>
							<tr>
								<td>Opis :</td>
								<td><form:textarea path="description" cols="50" rows="5"/>
								</td>
							</tr>
							<tr>
								<td colspan="2"><input type="submit" class="button"
									value="Dodaj"></td>
							</tr>
						</table>
					</form:form>
					</c:if>
					<c:if test="${testUserOwner == true}">
					<form:form action="myrestaurantedit.htm" commandName="userRestaurant">
						<table>
							<tr>
								<td colspan="2"><span class="text1"
									style="text-align: right">Edytuj Twoją restaurację:</span>
								<td />


							</tr>
							<tr>
								<td>Nazwa :</td>
								<td><input type="text" name="restname" value="${userRestaurant.name }" />
								</td>
								<td><span style="color: red"><c:out
											value="${restnameError}" /> </span></td>
<td >Logo :</td>
								
								</td>
								<td><span style="color: red"><c:out
											value="${restnameError}" /> </span></td>
							</tr>
							<tr>
								<td>Adres :</td>
								<td><input type="text" name="reststreet" value="${userRestaurant.street }" />
								</td>
								<td><span style="color: red"><c:out
											value="${reststreetError}" /> </span></td>
		<td rowspan="4"><img src="${logosource}" alt="alt text for image" />
							</tr>
							<tr>
								<td>Miasto:</td>
								<td><select name="restcity">
										<c:forEach items="${cities}" var="value">
											<option value="${value}"
												<c:if test="${userRestaurant.city == value}"> selected="selected" </c:if>>${value}</option>
										</c:forEach>
								</select></td>
							</tr>
							<tr>
								<td>Kraj:</td>
								<td><select name="restcountry">
										<c:forEach items="${countries}" var="value">
											<option value="${value}"
												<c:if test="${userRestaurant.country == value}"> selected="selected" </c:if>>${value}</option>
										</c:forEach>
								</select></td>
							</tr>
							<tr>
								<td>Kod pocztowy:</td>
								<td><input type="text" name="restpostal_code"
									value="${userRestaurant.postal_code}" />
								</td>
								<td><span style="color: red"><c:out
											value="${resttelephoneError}" /> </span></td>

							</tr>
							<tr>
								<td>Telefon:</td>
								<td><input type="text" name="resttelephone"
									value="${userRestaurant.telephone}" />
								</td>
								<td><span style="color: red"><c:out
											value="${resttelephoneError}" /> </span></td>
								
								<td><span class="text2">Położenie geograficzne Twojej restauracji: <c:out value="${userRestaurant.longitude} : ${userRestaurant.latitude} " /></span></td>
							</tr>
							<tr>
								<td>Opis:</td>
								
								<td><textarea name="restdescription" cols="50" rows="5"><c:out value="${userRestaurant.description}" /></textarea>
								<td><span style="color: red"><c:out
											value="${resttelephoneError}" /> </span></td>
								<td><span class="text2">Ostatnia modyfikacja restauracji: <c:out value="${userRestaurant.last_update}" /></span><br/>
								<a href="/RestFinderWebApp/restaurantid=${userRestaurant.id }.htm">Idź do strony swojej restauracji</a></td>
							</tr>
							<tr>
								<td colspan="2"><input type="submit" class="button"
									value="Zmień dane restauracji">
								</td>
							</tr>
							
							
							
						</table>
				</form:form>
				<form:form action="changeatrakcja.htm" commandName="setTagAtrakcja">
				<table>
				<tr><td colspan="2"><span class="text1"
									style="text-align: right">Zmień tagi:</span></tr>
									<tr>
									<td colspan="3">Atrakcja:	<span class="text2" >Obecne Tagi: <c:out value="${setTagAtrakcja.tag }" /></span></td>
									</tr>
									<tr><td>
									<form:checkboxes delimiter="<br/>" items="${Atrakcja }" path="tag"/>
									 </td>
									 <td><input type="submit" class="button"
									value="Zmień"></td></tr>
				</table>
				</form:form>
				<form:form action="changepochodzenie.htm" commandName="setTagPochodzenie">
				<table>

									<tr>
									<td colspan="3">Pochodzenie:	<span class="text2" >Obecne Tagi: <c:out value="${setTagPochodzenie.tag }" /></span></td>
									</tr>
									<tr><td>
									<form:checkboxes delimiter="<br/>" items="${Pochodzenie }" path="tag"/>
									 </td>
									 <td><input type="submit" class="button"
									value="Zmień"></td></tr>
				</table>
				</form:form>
				<form:form action="changeskladnik.htm" commandName="setTagSkladnik">
				<table>

									<tr>
									<td colspan="3">Składnik:	<span class="text2" >Obecne Tagi: <c:out value="${setTagSkladnik.tag }" /></span></td>
									</tr>
									<tr><td>
									<form:checkboxes delimiter="<br/>" items="${Skladnik }" path="tag"/>
									 </td>
									 <td><input type="submit" class="button"
									value="Zmień"></td></tr>
				</table>
				</form:form>
				<form:form action="changesmak.htm" commandName="setTagSmak">
				<table>

									<tr>
									<td colspan="3">Smak:	<span class="text2" >Obecne Tagi: <c:out value="${setTagSmak.tag }" /></span></td>
									</tr>
									<tr><td>
									<form:checkboxes delimiter="<br/>" items="${Smak }" path="tag"/>
									 </td>
									 <td><input type="submit" class="button"
									value="Zmień"></td></tr>
				</table>
				</form:form>
				<form:form action="changetyp.htm" commandName="setTagTyp">
				<table>

									<tr>
									<td colspan="3">Typ:	<span class="text2" >Obecne Tagi: <c:out value="${setTagTyp.tag }" /></span></td>
									</tr>
									<tr><td>
									<form:checkboxes delimiter="<br/>" items="${Typ }" path="tag"/>
									 </td>
									 <td><input type="submit" class="button"
									value="Zmień"></td></tr>
				</table>
				</form:form>
				<form:form action="changeusluga.htm" commandName="setTagUsluga">
				<table>

									<tr>
									<td colspan="3">Usługa:	<span class="text2" >Obecne Tagi: <c:out value="${setTagUsluga.tag }" /></span></td>
									</tr>
									<tr><td>
									<form:checkboxes delimiter="<br/>" items="${Usluga }" path="tag"/>
									 </td>
									 <td><input type="submit" class="button"
									value="Zmień"></td></tr>
				</table>
				</form:form>
				<br/>
				<br/>
										<form:form action="myrestaurantdelete.htm" commandName="userRestaurant">
						<table>
						<td colspan="2"><span class="text1"
									style="text-align: right">Usun restaurację</span></tr><tr><td colspan="2"><input type="submit" class="button"
									value="Usuń"></td></tr></table>
								</form:form>	
				</c:if>
				</div>

<div id="box-four" style="height: 340px; overflow:scroll;">
<h3 style="text-align: center">Moja aktywność:</h3>
<c:if test="${followedRestaurant!=null }">Twoja śledzona restauracja: <br/>
 <a href="/RestFinderWebApp/restaurantid=${followedRestaurant.restaurant_id }.htm">Idź do strony restauracji</a> <br/><br/> </c:if>
Twoje ulubione restauracje:
<c:if test="${fn:length(favList) > 0}">
						<table cellpadding="5">
							<c:forEach items="${favList}" var="restaurant" varStatus="status">
								<tr>
								<td>${restaurant.name}</td>
								<td><a href="/RestFinderWebApp/restaurantid=${restaurant.id }.htm">Idź do strony restauracji</a></td>
								</tr>
							</c:forEach>
						</table>
					</c:if>
					
<br/>
Twoje komentarze:
<c:if test="${fn:length(commentList) > 0}">
						<table cellpadding="5">
							<c:forEach items="${commentList}" var="comment" varStatus="status">
								<tr>
								<td><c:out value="${comment.date}" /></td>
								</tr>
								<tr>
								<td><span"><c:out value="${comment.comment}" /></span></td>
								<tr>
							</c:forEach>
						</table>
					</c:if>
</div>


				<div id="box-one" style="height: 340px">
					<h3 style="text-align: center">Moje konto:</h3>
					<form:form action="changepassword.htm" commandName="user">
						<table>
							<tr>
								<td colspan="2"><span class="text1"
									style="text-align: right">Zmień hasło:</span>
								<td />


							</tr>
							<tr>
								<td>Stare hasło :</td>
								<td><input type="password" name="oldPassword" />
								</td>
								<td><span style="color: red"><c:out
											value="${oldPasswordError}" /> </span>
								</td>

							</tr>
							<tr>
								<td>Nowe hasło :</td>
								<td><input type="password" name="newPassword" />
								</td>
								<td><span style="color: red"><c:out
											value="${newPasswordError}" /> </span>
								</td>

							</tr>
							<tr>
								<td>Powtórz hasło:</td>
								<td><input type="password" name="confirmPassword" />
								</td>
								<td><span style="color: red"><c:out
											value="${confirmPasswordError}" /> </span>
								</td>

							</tr>
							<tr>
								<td colspan="2"><input type="submit" class="button"
									value="Zmień hasło"></td>
							</tr>
						</table>
					</form:form>
					<form:form action="changepreferences.htm" commandName="user">
						<table>
							<tr>
								<td colspan="2"><span class="text1"
									style="text-align: right; padding-left: 10px;">Zmień
										preferencje:</span>
								<td />


							</tr>
							<tr>
								<td><input type="checkbox" name="showTelephone"
									value="true"
									<c:if test="${user.show_my_telephone}">checked</c:if> /></td>
								<td>Pokazuj mój telefon</td>

							</tr>
							<tr>

								<td><input type="checkbox" name="showName" value="true"
									<c:if test="${user.show_my_name}">checked</c:if> /></td>
								<td>Pokazuj moje imię</td>

							</tr>
							<tr>

								<td><input type="checkbox" name="showAddress" value="true"
									<c:if test="${user.show_my_address}">checked</c:if> /></td>
								<td>Pokazuj mój adres</td>



							</tr>
							<tr>
								<td colspan="2"><input type="submit" class="button"
									value="Zmień preferencje"></td>
							</tr>
						</table>
					</form:form>
					<form:form action="changemobile.htm" commandName="user">
						<table>
							<tr>
								<td colspan="2"><span class="text1"
									style="text-align: right; padding-left: 10px;">Ustawienia
										telefonu:</span>
								<td />


							</tr>
							<tr>
								<td><input type="checkbox" name="mobileEnabled"
									value="true" <c:if test="${user.mobile_enabled}">checked</c:if> />
								</td>
								<td>Pokazuj mój telefon</td>

							</tr>

							<tr>
								<td colspan="2"><input type="submit" class="button"
									value="Zmień preferencje telefonu"></td>
							</tr>

						</table>
					</form:form>
				</div>

			</div>

		</div>
		<br /> <br /> <br /> <br />

		<table>
			<tr>
				<TD WIDTH=775 HEIGHT=47 COLSPAN=17 align="center" valign="middle"
					BGCOLOR=#979076 class="text4"></TD>
			</tr>
		</table>
	</center>
</BODY>

</HTML>